import 'package:bike_ride/common/util/hysize_fit.dart';
import 'package:bike_ride/res/style/color_styles.dart';
import 'package:flutter/material.dart';

/// 数据行展示
class InfoRowWidget extends StatelessWidget {
  final Object? left;
  final Object? center;
  final Object? right;
  final EdgeInsets? padding;

  /// 颜色
  final Color? leftColor;
  final Color? centerColor;
  final Color? rightColor;

  /// 字体大小
  final double? leftFontSize;
  final double? centerFontSize;
  final double? rightFontSize;

  const InfoRowWidget(
      {super.key,
      this.left,
      this.center,
      this.right,
      this.padding,
      this.leftColor,
      this.centerColor,
      this.rightColor,
      this.leftFontSize,
      this.centerFontSize,
      this.rightFontSize});

  @override
  Widget build(BuildContext context) {
    final leftTextStyle = TextStyle(
      fontSize: leftFontSize ?? 32.rpx,
      color: leftColor ?? ColorStyles.color_333333,
    );
    final centerTextStyle = TextStyle(
      fontSize: centerFontSize ?? 32.rpx,
      color: centerColor ?? ColorStyles.color_333333,
    );
    final rightTextStyle = TextStyle(
      fontSize: rightFontSize ?? 32.rpx,
      color: rightColor ?? ColorStyles.color_333333,
    );
    return Container(
      color: Colors.white,
      padding:
          padding ?? EdgeInsets.symmetric(horizontal: 28.rpx, vertical: 22.rpx),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          if (left != null)
            left is String
                ? Text(
                    left as String,
                    style: leftTextStyle,
                  )
                : left as Widget,
          Row(
            mainAxisSize: MainAxisSize.min,
            children: [
              if (center != null)
                center is String
                    ? Text(
                        center as String,
                        style: centerTextStyle,
                      )
                    : center as Widget,
              if (right != null)
                right is String
                    ? Text(
                        right as String,
                        style: rightTextStyle,
                      )
                    : right as Widget
            ],
          )
        ],
      ),
    );
  }
}
